#include "Framework/Abstract/AbstractTask.hh"

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE AbstractTaskTests
#include <boost/test/unit_test.hpp>

using namespace Framework;

class SimpleTask : public AbstractTask
{
	public:
		typedef boost::shared_ptr< AbstractTask > Ptr;

	protected:
		virtual void run()
		{
			BOOST_TEST_MESSAGE( "Some simple calculations." );
		}
};

class SimpleSubscriber : public Common::Patterns::Subscriber
{
	public:
		typedef boost::shared_ptr< SimpleSubscriber > Ptr;

	private:
		std::string iDescription;

	public:
		SimpleSubscriber( std::string aDescription ) : iDescription( aDescription ) {};

		virtual void notify() { BOOST_TEST_MESSAGE( iDescription ); };
};

BOOST_AUTO_TEST_CASE( SimpleTaskRun_Test )
{
	SimpleTask::Ptr task = SimpleTask::Ptr( new SimpleTask() );

	SimpleSubscriber::Ptr s1 = SimpleSubscriber::Ptr( new SimpleSubscriber( "Task is about to start." ) );
	SimpleSubscriber::Ptr s2 = SimpleSubscriber::Ptr( new SimpleSubscriber( "Task stopped." ) );

	task->startTaskPublisher.attach( s1 );
	task->stopTaskPublisher.attach( s2 );
	task->start();
}
